package com.longrise.android.byjk.plugins.aboutme;

import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;

import com.longrise.android.byjk.R;
import com.longrise.common.base.BaseActivity;
import com.longrise.common.utils.DZZWTools;

/**
 * 关于保宝
 */
public class AboutBBTLFView extends BaseActivity implements OnClickListener {


    @Override
    public int getContentViewId(@Nullable Bundle savedInstanceState) {
        return R.layout.lfview_aboutbbt;
    }

    @Override
    public void initView() {
        TextView version = (TextView) findViewById(R.id.text_version);
        version.setText("保宝 " + getVersionCode());

        TextView tvDate = (TextView) findViewById(R.id.aboutbbt_text_year);
        setCopyright(tvDate);

        initTitle();

    }

    private void initTitle() {
        Toolbar mTitle = (Toolbar) findViewById(R.id.byjk_toolbar);
        mTitle.setTitle("关于保宝");
        mTitle.setNavigationOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }

    private void setCopyright(TextView view) {
        String year = DZZWTools.getSystemTime("yyyy");
        view.setText("深圳市永兴元科技股份有限公司\u3000版权所有\ncopyright\u0020@\u00201998-" + year + "\u0020深圳市永兴元科技股份有限公司");
    }

    private String getVersionCode() {
        String versionString = "";
        try {
            PackageManager manager = getPackageManager();
            PackageInfo infor = manager.getPackageInfo(getPackageName(), 0);
            versionString = infor.versionName;
        } catch (NameNotFoundException e) {
            e.printStackTrace();
        }
        return versionString;
    }

    @Override
    public void onClick(View v) {
    }
}
